<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('建档项目库')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>项目名称：</p>
                                <input type="text" name="projectName"/>
                            </li>
                            <li>
							项目类型：<select name="projectType" th:with="type=${@dict.getType('sys_normal_disable')}">
							            <option value="">全部</option>
										<option value="房建">房建</option>
										<option value="市政">市政</option>
								   </select>
							</li>  
                            <li>
                            <li>
								<label>总金额： </label>
								<input style="width:100px" type="text" name="beginProjectCost" placeholder="最小总金额"/>
								<span>-</span>
								<input style="width:105px" type="text" name="endProjectCost" placeholder="最大总金额"/>
							</li>
                            <li>
								<label>总规模： </label>
								<input style="width:100px" type="text" name="beginTotalArea" placeholder="最小规模"/>
								<span>-</span>
								<input style="width:105px" type="text" name="endTotalArea" placeholder="最大规模"/>
							</li>
                            <li>
							项目状态：<select name="projectState" th:with="type=${@dict.getType('sys_normal_disable')}">
							            <option value="">全部</option>
										<option value="在建">在建</option>
										<option value="已竣工备案">竣工</option>
								   </select>
							</li> 
							<li>
							是否关注：<select name="isFocus" th:with="type=${@dict.getType('sys_normal_disable')}">
							            <option value="">不限</option>
										<option value="1">关注</option>
										<option value="0">未关注</option>
								   </select>
							</li> 
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                 <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/js/plugins/datetime/moment.js}"></script>
    <script th:inline="javascript">
    var prefix = ctx + "tbFocusProject/tbFocusProject";
    
    $(function() {
    	 var options = {
    			url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                detailUrl: prefix + "/detail/{id}",
                modalName: "项目",
                columns: [{
                        field: 'id',
                        title: '序号',
						formatter: function (value, row, index) {
						
						    return index + 1;
						}
                    },
                    {
                        field: 'guid',
                        title: '项目编码',
						visible: false
	                }, 
					{
                        field: 'projectName',
                        title: '项目名称'
                    },
                    {
                        field: 'constructUnitId',
                        title: '建设单位'
                    },
                    {
                        field: 'totalArea',
                        title: '总规模(㎡)'
                    },
                    {
                        field: 'projectCost',
                        title: ' 总金额(万)'
                    },
                    {
                        field: 'projectAddress',
                        title: '项目地址'
                    },
                    {
                        field: 'isFocus',
                        title: '是否关注',
						visible: false
                    },
					{
					    title: '操作',
					    align: 'center',
					    formatter: function(value, row, index) {
					        var actions = [];
					        if(row.isFocus == '0'){
					        	actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="follow(\'' + row.guid + '\', \'' + row.projectName + '\',1, \'' + '关注' + '\')"><i class="fa fa-edit"></i>关注</a> ');
					        }else if(row.isFocus == '1'){
					        	actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="follow(\'' + row.guid + '\', \'' + row.projectName + '\',0, \'' + '取消关注' + '\')"><i class="fa fa-remove"></i>取消关注</a> ');
					        }
					        return actions.join('');
					    }
					}]
        };
    	$.table.init(options);
    });
    
    /* 关注 */
	function follow(guid,projectName,isFocus,focus) {
    	var TbFocusProject= {};
    	TbFocusProject.guid = guid;
    	TbFocusProject.isFocus = isFocus;
    	TbFocusProject.updateTime = moment().locale('zh-cn').format('YYYY-MM-DD HH:mm:ss.SSS');
		$.modal.confirm("确认要"+focus+projectName+"项目吗？", function() {
			 $.operate.submit(prefix + "/follow", "post", "json", TbFocusProject);
	    })
	}
    </script>
</body>
</html>